package com.vp.org.dao.impl;

import com.vp.org.constant.OrderSql;
import com.vp.org.dao.OrderDao;
import com.vp.org.pojo.Orders;
import com.vp.org.util.JdbcUtil;
import org.springframework.jdbc.core.BeanPropertyRowMapper;

import java.util.List;

public class OrderDaoImpl extends JdbcUtil implements OrderDao, OrderSql {

    @Override
    public int addOrders(Orders orders) {
        return template.update(ADD_ORDERS, orders.getOrderNum(), orders.getUserId(),
                orders.getOrderName(), orders.getStatus(), orders.getPrice(),
                orders.getCount(), orders.getPhone(), orders.getGoodsName());
    }

    @Override
    public List<Orders> queryOrders(int id) {
        return template.query(QUERY_ORDERS, new BeanPropertyRowMapper<>(Orders.class), id);
    }
}
